<template>
  <div class="supplier">
    <c-desc
      :data="supplierData"
      :column="3"
      :columns="columns"
      bordered
      size="small"
      layout="vertical"
    >
      <template v-slot:term>
        <span>{{ getDate(supplierData.termStart) }}</span>
        <span> 至 </span>
        <span>{{ getDate(supplierData.termEnd) }}</span>
      </template>
      <template v-slot:startDate>
        <span>{{ getDate(supplierData.startDate) }}</span>
      </template>
      <template v-slot:checkDate>
        <span>{{ getDate(supplierData.checkDate) }}</span>
      </template>
    </c-desc>
  </div>
</template>

<script>
import { getcompanyqccinfobyid } from "@/api/company";

export default {
  props: {
    quotationData: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  data() {
    return {
      supplierData: {},
      columns: [
        {
          label: "法定代表人",
          prop: "operName"
        },
        {
          label: "经营状态",
          prop: "status"
        },
        {
          label: "成立日期",
          prop: "startDate",
          slot: "startDate"
        },
        {
          label: "注册资本",
          prop: "registCapi"
        },
        {
          label: "实缴资本",
          prop: "recCap"
        },
        {
          label: "核准日期",
          prop: "checkDate",
          slot: "checkDate"
        },
        {
          label: "统一社会信用代码",
          prop: "creditCode"
        },
        {
          label: "组织机构代码",
          prop: "orgNo"
        },
        {
          label: "工商注册号",
          prop: "no"
        },
        {
          label: "纳税人识别号",
          prop: "creditCode"
        },
        {
          label: "进出口企业代码",
          prop: "ixCode"
        },
        {
          label: "所属行业",
          prop: "subIndustry"
        },
        {
          label: "企业类型",
          prop: "econKind"
        },
        {
          label: "营业期限",
          prop: "term",
          slot: "term"
        },
        {
          label: "登记机关",
          prop: "belongOrg"
        },
        {
          label: "人员规模",
          prop: "personScope"
        },
        {
          label: "参保人数",
          prop: "insuredCount"
        },
        {
          label: "所属地区",
          prop: "province"
        },
        {
          label: "曾用名",
          prop: "originalName"
        },
        {
          label: "英文名",
          prop: "englishName",
          span: 2
        },
        {
          label: "企业地址",
          prop: "address",
          span: 3
        },
        {
          label: "经营范围",
          prop: "scope",
          span: 3
        }
      ]
    };
  },
  methods: {
    getSupplierInfo() {
      getcompanyqccinfobyid({
        companyId: this.quotationData.companyId
      }).then(res => {
        this.supplierData = res;
      });
    },
    // 截取日期，因为返回的日期带有时分秒
    getDate(date) {
      let res;
      if (date) res = date.split(" ")[0];
      return res;
    }
  },
  created() {
    this.getSupplierInfo();
  }
};
</script>
